



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class LmsErrorsDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public LmsErrorsDB()
        {
        }

        public LmsErrorsDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<LmsErrors> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<LmsErrors> lstRet = new List<LmsErrors>();

            string strQuery = " select " + strTop  + " * from dbo.[LmsErrors]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    LmsErrors obj = new LmsErrors();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["ErrSender"] != DBNull.Value)
                    {
                        obj.ErrSender = (System.String)dr["ErrSender"];
                    }
                    else
                    {
                        obj.ErrSender = "";
                    } 
 if (dr["ErrData"] != DBNull.Value)
                    {
                        obj.ErrData = (System.String)dr["ErrData"];
                    }
                    else
                    {
                        obj.ErrData = "";
                    } 
 if (dr["ErrMessage"] != DBNull.Value)
                    {
                        obj.ErrMessage = (System.String)dr["ErrMessage"];
                    }
                    else
                    {
                        obj.ErrMessage = "";
                    } 
 if (dr["ErrStackTrace"] != DBNull.Value)
                    {
                        obj.ErrStackTrace = (System.String)dr["ErrStackTrace"];
                    }
                    else
                    {
                        obj.ErrStackTrace = "";
                    } 
 if (dr["ErrToString"] != DBNull.Value)
                    {
                        obj.ErrToString = (System.String)dr["ErrToString"];
                    }
                    else
                    {
                        obj.ErrToString = "";
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<LmsErrors> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<LmsErrors> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , LmsErrors obj)
        {
            
            

                    DbParameter prmErrSender = con.createParameter();
                    prmErrSender.ParameterName = "@ErrSender";
                    prmErrSender.DbType =DbType.String;
                    if (obj.ErrSender == null)
                    {
                        prmErrSender.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrSender.Value = obj.ErrSender;
                    }
                

                    


                    DbParameter prmErrData = con.createParameter();
                    prmErrData.ParameterName = "@ErrData";
                    prmErrData.DbType =DbType.String;
                    if (obj.ErrData == null)
                    {
                        prmErrData.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrData.Value = obj.ErrData;
                    }
                

                    


                    DbParameter prmErrMessage = con.createParameter();
                    prmErrMessage.ParameterName = "@ErrMessage";
                    prmErrMessage.DbType =DbType.String;
                    if (obj.ErrMessage == null)
                    {
                        prmErrMessage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrMessage.Value = obj.ErrMessage;
                    }
                

                    


                    DbParameter prmErrStackTrace = con.createParameter();
                    prmErrStackTrace.ParameterName = "@ErrStackTrace";
                    prmErrStackTrace.DbType =DbType.String;
                    if (obj.ErrStackTrace == null)
                    {
                        prmErrStackTrace.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrStackTrace.Value = obj.ErrStackTrace;
                    }
                

                    


                    DbParameter prmErrToString = con.createParameter();
                    prmErrToString.ParameterName = "@ErrToString";
                    prmErrToString.DbType =DbType.String;
                    if (obj.ErrToString == null)
                    {
                        prmErrToString.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrToString.Value = obj.ErrToString;
                    }
                

                    


           



            string strQuery = " insert into dbo.[LmsErrors] ([ErrSender],[ErrData],[ErrMessage],[ErrStackTrace],[ErrToString]) VALUES (@ErrSender,@ErrData,@ErrMessage,@ErrStackTrace,@ErrToString) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmErrSender,prmErrData,prmErrMessage,prmErrStackTrace,prmErrToString);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(LmsErrors obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, LmsErrors obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmErrSender = con.createParameter();
                    prmErrSender.ParameterName = "@ErrSender";
                    prmErrSender.DbType =DbType.String;
                    if (obj.ErrSender == null)
                    {
                        prmErrSender.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrSender.Value = obj.ErrSender;
                    }
                

                    


                    DbParameter prmErrData = con.createParameter();
                    prmErrData.ParameterName = "@ErrData";
                    prmErrData.DbType =DbType.String;
                    if (obj.ErrData == null)
                    {
                        prmErrData.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrData.Value = obj.ErrData;
                    }
                

                    


                    DbParameter prmErrMessage = con.createParameter();
                    prmErrMessage.ParameterName = "@ErrMessage";
                    prmErrMessage.DbType =DbType.String;
                    if (obj.ErrMessage == null)
                    {
                        prmErrMessage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrMessage.Value = obj.ErrMessage;
                    }
                

                    


                    DbParameter prmErrStackTrace = con.createParameter();
                    prmErrStackTrace.ParameterName = "@ErrStackTrace";
                    prmErrStackTrace.DbType =DbType.String;
                    if (obj.ErrStackTrace == null)
                    {
                        prmErrStackTrace.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrStackTrace.Value = obj.ErrStackTrace;
                    }
                

                    


                    DbParameter prmErrToString = con.createParameter();
                    prmErrToString.ParameterName = "@ErrToString";
                    prmErrToString.DbType =DbType.String;
                    if (obj.ErrToString == null)
                    {
                        prmErrToString.Value = DBNull.Value;
                    }
                    else
                    {
                        prmErrToString.Value = obj.ErrToString;
                    }
                

                    


           



            string strQuery = " update dbo.[LmsErrors] set [ErrSender]=@ErrSender,[ErrData]=@ErrData,[ErrMessage]=@ErrMessage,[ErrStackTrace]=@ErrStackTrace,[ErrToString]=@ErrToString where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmErrSender,prmErrData,prmErrMessage,prmErrStackTrace,prmErrToString);

            

        }


        public void Update(LmsErrors obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, LmsErrors obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[LmsErrors]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( LmsErrors obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<LmsErrors> getLmsErrorsByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByID(System.Int64 ID)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<LmsErrors> getLmsErrorsByErrSender(ClassDataHandler con,System.String ErrSender)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmErrSender = con.createParameter();
                        prmErrSender.ParameterName = "@ErrSender";
                        prmErrSender.DbType = DbType.String;
                        if (ErrSender == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmErrSender.Value = ErrSender;
                        }


                        lstRet = Select(con, "" , " where [ErrSender]=@ErrSender ", prmErrSender);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByErrSender(System.String ErrSender)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByErrSender(con, ErrSender);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<LmsErrors> getLmsErrorsByErrData(ClassDataHandler con,System.String ErrData)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmErrData = con.createParameter();
                        prmErrData.ParameterName = "@ErrData";
                        prmErrData.DbType = DbType.String;
                        if (ErrData == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmErrData.Value = ErrData;
                        }


                        lstRet = Select(con, "" , " where [ErrData]=@ErrData ", prmErrData);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByErrData(System.String ErrData)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByErrData(con, ErrData);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<LmsErrors> getLmsErrorsByErrMessage(ClassDataHandler con,System.String ErrMessage)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmErrMessage = con.createParameter();
                        prmErrMessage.ParameterName = "@ErrMessage";
                        prmErrMessage.DbType = DbType.String;
                        if (ErrMessage == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmErrMessage.Value = ErrMessage;
                        }


                        lstRet = Select(con, "" , " where [ErrMessage]=@ErrMessage ", prmErrMessage);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByErrMessage(System.String ErrMessage)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByErrMessage(con, ErrMessage);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<LmsErrors> getLmsErrorsByErrStackTrace(ClassDataHandler con,System.String ErrStackTrace)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmErrStackTrace = con.createParameter();
                        prmErrStackTrace.ParameterName = "@ErrStackTrace";
                        prmErrStackTrace.DbType = DbType.String;
                        if (ErrStackTrace == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmErrStackTrace.Value = ErrStackTrace;
                        }


                        lstRet = Select(con, "" , " where [ErrStackTrace]=@ErrStackTrace ", prmErrStackTrace);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByErrStackTrace(System.String ErrStackTrace)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByErrStackTrace(con, ErrStackTrace);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<LmsErrors> getLmsErrorsByErrToString(ClassDataHandler con,System.String ErrToString)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();


                        DbParameter prmErrToString = con.createParameter();
                        prmErrToString.ParameterName = "@ErrToString";
                        prmErrToString.DbType = DbType.String;
                        if (ErrToString == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmErrToString.Value = ErrToString;
                        }


                        lstRet = Select(con, "" , " where [ErrToString]=@ErrToString ", prmErrToString);



                        return lstRet;

                    }


                    public List<LmsErrors> getLmsErrorsByErrToString(System.String ErrToString)
                    {
                        List<LmsErrors> lstRet = new List<LmsErrors>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getLmsErrorsByErrToString(con, ErrToString);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<LmsErrors> Search(ClassDataHandler con, LmsErrors obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.ErrSender != "")
                    {
                        DbParameter prmErrSender = con.createParameter();
                        prmErrSender.ParameterName = "@ErrSender";
                        prmErrSender.DbType =DbType.String;
                        if (obj.ErrSender == null)
                        {
                            prmErrSender.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrSender.Value = obj.ErrSender;
                        }
                        strWhere += " [ErrSender]=@ErrSender AND ";
                        lstParameters.Add(prmErrSender);
                     }



                    

                    if (obj.ErrData != "")
                    {
                        DbParameter prmErrData = con.createParameter();
                        prmErrData.ParameterName = "@ErrData";
                        prmErrData.DbType =DbType.String;
                        if (obj.ErrData == null)
                        {
                            prmErrData.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrData.Value = obj.ErrData;
                        }
                        strWhere += " [ErrData]=@ErrData AND ";
                        lstParameters.Add(prmErrData);
                     }



                    

                    if (obj.ErrMessage != "")
                    {
                        DbParameter prmErrMessage = con.createParameter();
                        prmErrMessage.ParameterName = "@ErrMessage";
                        prmErrMessage.DbType =DbType.String;
                        if (obj.ErrMessage == null)
                        {
                            prmErrMessage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrMessage.Value = obj.ErrMessage;
                        }
                        strWhere += " [ErrMessage]=@ErrMessage AND ";
                        lstParameters.Add(prmErrMessage);
                     }



                    

                    if (obj.ErrStackTrace != "")
                    {
                        DbParameter prmErrStackTrace = con.createParameter();
                        prmErrStackTrace.ParameterName = "@ErrStackTrace";
                        prmErrStackTrace.DbType =DbType.String;
                        if (obj.ErrStackTrace == null)
                        {
                            prmErrStackTrace.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrStackTrace.Value = obj.ErrStackTrace;
                        }
                        strWhere += " [ErrStackTrace]=@ErrStackTrace AND ";
                        lstParameters.Add(prmErrStackTrace);
                     }



                    

                    if (obj.ErrToString != "")
                    {
                        DbParameter prmErrToString = con.createParameter();
                        prmErrToString.ParameterName = "@ErrToString";
                        prmErrToString.DbType =DbType.String;
                        if (obj.ErrToString == null)
                        {
                            prmErrToString.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrToString.Value = obj.ErrToString;
                        }
                        strWhere += " [ErrToString]=@ErrToString AND ";
                        lstParameters.Add(prmErrToString);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<LmsErrors> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<LmsErrors> Search(LmsErrors obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<LmsErrors> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<LmsErrors> SearchOrLike(ClassDataHandler con, LmsErrors obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.ErrSender != "")
                    {
                        DbParameter prmErrSender = con.createParameter();
                        prmErrSender.ParameterName = "@ErrSender";
                        prmErrSender.DbType =DbType.String;
                        if (obj.ErrSender == null)
                        {
                            prmErrSender.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrSender.Value = obj.ErrSender;
                        }
                        strWhere += " [ErrSender] LIKE @ErrSender OR ";
                        lstParameters.Add(prmErrSender);
                     }



                    

                    if (obj.ErrData != "")
                    {
                        DbParameter prmErrData = con.createParameter();
                        prmErrData.ParameterName = "@ErrData";
                        prmErrData.DbType =DbType.String;
                        if (obj.ErrData == null)
                        {
                            prmErrData.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrData.Value = obj.ErrData;
                        }
                        strWhere += " [ErrData] LIKE @ErrData OR ";
                        lstParameters.Add(prmErrData);
                     }



                    

                    if (obj.ErrMessage != "")
                    {
                        DbParameter prmErrMessage = con.createParameter();
                        prmErrMessage.ParameterName = "@ErrMessage";
                        prmErrMessage.DbType =DbType.String;
                        if (obj.ErrMessage == null)
                        {
                            prmErrMessage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrMessage.Value = obj.ErrMessage;
                        }
                        strWhere += " [ErrMessage] LIKE @ErrMessage OR ";
                        lstParameters.Add(prmErrMessage);
                     }



                    

                    if (obj.ErrStackTrace != "")
                    {
                        DbParameter prmErrStackTrace = con.createParameter();
                        prmErrStackTrace.ParameterName = "@ErrStackTrace";
                        prmErrStackTrace.DbType =DbType.String;
                        if (obj.ErrStackTrace == null)
                        {
                            prmErrStackTrace.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrStackTrace.Value = obj.ErrStackTrace;
                        }
                        strWhere += " [ErrStackTrace] LIKE @ErrStackTrace OR ";
                        lstParameters.Add(prmErrStackTrace);
                     }



                    

                    if (obj.ErrToString != "")
                    {
                        DbParameter prmErrToString = con.createParameter();
                        prmErrToString.ParameterName = "@ErrToString";
                        prmErrToString.DbType =DbType.String;
                        if (obj.ErrToString == null)
                        {
                            prmErrToString.Value = DBNull.Value;
                        }
                        else
                        {
                            prmErrToString.Value = obj.ErrToString;
                        }
                        strWhere += " [ErrToString] LIKE @ErrToString OR ";
                        lstParameters.Add(prmErrToString);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<LmsErrors> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<LmsErrors> SearchOrLike(LmsErrors obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<LmsErrors> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            